package 公司真题.携程;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class _符合条件的订单号 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = Integer.parseInt(sc.nextLine());
        long time = Long.parseLong(sc.nextLine());
        List<Integer> res = new LinkedList<>();
        while (count > 0) {
            String str = sc.nextLine();
            String[] strArr = str.split(" ");
            long begin = Long.parseLong(strArr[1]);
            long end = Long.parseLong(strArr[2]);
            if (time >= begin && time <= end) {
                res.add(Integer.parseInt(strArr[0]));
            }
            count--;
        }
        if (res.size() == 0) {
            System.out.println("null");
            System.exit(0);
        }
        Integer[] arr = res.toArray(new Integer[]{});
        Arrays.sort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
